//	ID : pallab81
// 	PROG : 10261
// 	LANG : C++
// 	2011-07-21-13.23.08 Thursday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define fo(i,ed) for(int i = 0 ; i < ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

const int inf = (int)10000;
int dp[210][inf+100];
int w[ 210 ];
int n;
int len;
inline void read() {
    scanf("%d",&len);
    len*=100;
    n=0;
    while( scanf("%d",&w[n]) ) {
        if( w[n]==0 )break;
        ++n;
    }
}
inline int go(int i, int s1, int s2) {
    if(i==n) {
        return 0;
    }
    int &best = dp[i][ s1 ];
    if( best!=-1 )return best;
    best = 0;
    if( s1 >= w[i] && s2 >=w[i] ) {
        int a = 1+go(i+1, s1-w[i], s2);
        int b = 1+go(i+1,s1,s2-w[i]);
        best = max(a,b);
    } else if( s1 >= w[i] && s2< w[i] ) {
        int a = 1+go(i+1, s1-w[i], s2);
        best = a;
    } else if( s1 < w[i] && s2 >=w[i] ) {
        int a = 1+go(i+1, s1, s2-w[i]);
        best = a;
    }
    return best;
}
inline void bk(int i, int s1 , int s2) {
    if(i==n) {
        return ;
    }
    if( s1>=w[i] && s2>=w[i]) {
        if( 1+go(i+1,s1-w[i],s2) > 1+go(i+1,s1,s2-w[i]) ) {
            printf("port\n");
            bk(i+1,s1-w[i],s2);
        } else {
            printf("starboard\n");
            bk(i+1,s1,s2-w[i]);
        }
    } else if( s1 >=w[i] && s2<w[i] ) {
        printf("port\n");
        bk(i+1,s1-w[i],s2);
    } else if( s1 < w[i] && s2 >=w[i] ) {
        printf("starboard\n");
        bk(i+1,s1,s2-w[i]);
    }
}

inline void proc() {
    SET(dp,-1);
    int var = go(0,len,len);
    printf("%d\n",var);
    bk(0,len,len);
}

int main() {
    //cout<<sizeof(dp)/1024/1024<<"\n";
#ifndef ONLINE_JUDGE
    freopen("in.txt","rt",stdin);
#endif
    int cases;
    string line = "";
    for( scanf("%d",&cases); cases; --cases ) {
        read();
        printf("%s",line.c_str());
        proc();
        line = "\n";
    }

    return 0;
}


